package com.ruoyi.zxjd.work.mapper;

import com.ruoyi.zxjd.work.domain.*;

/**
 * @author fjhua
 * @create 2021-04-15 10:55
 */
public class WorkTemplateProxy {


    private WorkTemplateTable1Mapper workTemplateTable1Mapper;

    private WorkTemplateTable2Mapper workTemplateTable2Mapper;

    private WorkTemplateTable3Mapper workTemplateTable3Mapper;

    private WorkTemplateTable4Mapper workTemplateTable4Mapper;

    private WorkTemplateTable5Mapper workTemplateTable5Mapper;

    private WorkTemplateTable6Mapper workTemplateTable6Mapper;

    private WorkTemplateTable7Mapper workTemplateTable7Mapper;

    private WorkTemplateTable8Mapper workTemplateTable8Mapper;

    private WorkTemplateTable9Mapper workTemplateTable9Mapper;


    /**
     * 标签, 标识哪个mapper有值
     */
    private Integer flag = null;

    private WorkTemplateProxy() {
    }


    public static WorkTemplateProxy builder(Object object) {
        WorkTemplateProxy proxy = new WorkTemplateProxy();
        if (object instanceof WorkTemplateTable1Mapper) {
            proxy.workTemplateTable1Mapper = (WorkTemplateTable1Mapper) object;
            proxy.flag = 1;
        } else if (object instanceof WorkTemplateTable2Mapper) {
            proxy.workTemplateTable2Mapper = (WorkTemplateTable2Mapper) object;
            proxy.flag = 2;
        } else if (object instanceof WorkTemplateTable3Mapper) {
            proxy.workTemplateTable3Mapper = (WorkTemplateTable3Mapper) object;
            proxy.flag = 3;
        } else if (object instanceof WorkTemplateTable4Mapper) {
            proxy.workTemplateTable4Mapper = (WorkTemplateTable4Mapper) object;
            proxy.flag = 4;
        } else if (object instanceof WorkTemplateTable5Mapper) {
            proxy.workTemplateTable5Mapper = (WorkTemplateTable5Mapper) object;
            proxy.flag = 5;
        } else if (object instanceof WorkTemplateTable6Mapper) {
            proxy.workTemplateTable6Mapper = (WorkTemplateTable6Mapper) object;
            proxy.flag = 6;
        } else if (object instanceof WorkTemplateTable7Mapper) {
            proxy.workTemplateTable7Mapper = (WorkTemplateTable7Mapper) object;
            proxy.flag = 7;
        } else if (object instanceof WorkTemplateTable8Mapper) {
            proxy.workTemplateTable8Mapper = (WorkTemplateTable8Mapper) object;
            proxy.flag = 8;
        } else if (object instanceof WorkTemplateTable9Mapper) {
            proxy.workTemplateTable9Mapper = (WorkTemplateTable9Mapper) object;
            proxy.flag = 9;
        } else {
            throw new RuntimeException("代理对象异常");
        }

        return proxy;
    }


    public void insert(Object object) {

        switch (flag) {
            case 1:
                workTemplateTable1Mapper.insertWorkTemplateTable1((WorkTemplateTable1) object);
                break;
            case 2:
                workTemplateTable2Mapper.insertWorkTemplateTable2((WorkTemplateTable2) object);
                break;
            case 3:
                workTemplateTable3Mapper.insertWorkTemplateTable3((WorkTemplateTable3) object);
                break;
            case 4:
                workTemplateTable4Mapper.insertWorkTemplateTable4((WorkTemplateTable4) object);
                break;
            case 5:
                workTemplateTable5Mapper.insertWorkTemplateTable5((WorkTemplateTable5) object);
            case 6:
                workTemplateTable6Mapper.insertWorkTemplateTable6((WorkTemplateTable6) object);
                break;
            case 7:
                workTemplateTable7Mapper.insertWorkTemplateTable7((WorkTemplateTable7) object);
                break;
            case 8:
                workTemplateTable8Mapper.insertWorkTemplateTable8((WorkTemplateTable8) object);
                break;
            case 9:
                workTemplateTable9Mapper.insertWorkTemplateTable9((WorkTemplateTable9) object);
                break;
            default:
                throw new RuntimeException("代理异常");
        }
    }

    /**
     * 待测试
     *
     * @param object
     */
    public void updateById(Object object) {
        switch (flag) {
            case 1:
                workTemplateTable1Mapper.updateWorkTemplateTable1((WorkTemplateTable1) object);
                break;
            case 2:
                workTemplateTable2Mapper.updateWorkTemplateTable2((WorkTemplateTable2) object);
                break;
            case 3:
                workTemplateTable3Mapper.updateWorkTemplateTable3((WorkTemplateTable3) object);
                break;
            case 4:
                workTemplateTable4Mapper.updateWorkTemplateTable4((WorkTemplateTable4) object);
                break;
            case 5:
                workTemplateTable5Mapper.updateWorkTemplateTable5((WorkTemplateTable5) object);
                break;
            case 6:
                workTemplateTable6Mapper.updateWorkTemplateTable6((WorkTemplateTable6) object);
                break;
            case 7:
                workTemplateTable7Mapper.updateWorkTemplateTable7((WorkTemplateTable7) object);
                break;
            case 8:
                workTemplateTable8Mapper.updateWorkTemplateTable8((WorkTemplateTable8) object);
                break;
            case 9:
                workTemplateTable9Mapper.updateWorkTemplateTable9((WorkTemplateTable9) object);
                break;
            default:
                throw new RuntimeException("代理异常");
        }
    }


}
